package com.hanfu.ucenter.web.web.util;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

public class MapUtils {
	
	
	public final static MapKeyComparator mapKeyComparator=new MapKeyComparator();

	/**
	 * 让 Map按key进行排序,升序
	 */
	public static Map<String, String> sortMapByKey(Map<String, String> map) {
		if (map == null || map.isEmpty()) {
			return null;
		}
		Map<String, String> sortMap = new TreeMap<String, String>(mapKeyComparator);
		sortMap.putAll(map);
		return sortMap;
	}
	

    static class MapKeyComparator implements Comparator<String> {
		@Override
		public int compare(String s1, String s2) {
			return s1.compareTo(s2);  //从小到大排序
	
		}
    }
	
//    public static void main(String[] args) {
//        String aa = MapUtils.getCityByLngAndLat("121.473662", "31.230372");
//        System.out.println(aa);
//
//    }

}
